home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5156 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: CARNet.hr!tilia!ov30801
  2. From: ov30801@tilia.cc.fer.hr (oliver-marin vidovic)
  3. Newsgroups: comp.lang.c
  4. Subject: Random Numbers Help Needed
  5. Date: 7 Feb 1996 14:27:25 GMT
  6. Organization: CARNet, CROATIA
  7. Distribution: world
  8. Message-ID: <4facsd$lch@bagan.srce.hr>
  9. NNTP-Posting-Host: tilia.cc.etf.hr
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=US-ASCII
  12. Content-Transfer-Encoding: 7bit
  13. X-Newsreader: TIN [version 1.2 PL2]
  14.  
  15.  
  16.  Hi! I have a problem involving random number generator.
  17.  In my program I need a list of random numbers, but I don't want
  18. them to be the same every time I start the program. Now, I know I
  19. have to change the seed by srand function, but if I put the argument 
  20. to be constant, then srand is of no use. Therefore, i came to conclusion
  21. that i have to make the argument of srand every time different. 
  22.  So, my idea was to use the computer clock somehow, and to take
  23. time as the seed, since that can hardly be the same every time I
  24. start the program. But, there is something wrong when I try to make
  25. something with functions from time.h.
  26. (maybe I don't use them in right way, or maybe the whole idea is wrong)
  27.  
  28. Is there someone who can help me?!
  29. Thanks.
  30.  
  31. --
  32. ------------------------------------------------------------------  +   +
  33. ----  Oliver M. Vidovic (Jombo)        FER (Zagreb, Croatia)  ----    +  
  34. ---- e-mail: ov30801@pinus.cc.fer.hr -----------------------------  \___/
  35.